package net.mthotel.service;

import net.mthotel.entity.User;
import net.mthotel.repository.UserRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by dengry on 15/3/21.
 */
@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserRepository userRepository;


    @Override
    public boolean getUserByUsernameAndPassword(String username, String password) {
        User u = userRepository.getUserByUsernameAndPassword(username, password);
        if (u!=null) {
            return true;
        }
        return false;
    }

    @Override
    public boolean getUserByUsername(String username) {
        User u = userRepository.getUserByUsername(username);
        if (u!=null) {
            return false;
        }
        return true;
    }

    @Override
    public void saveUser(User user) {
        userRepository.save(user);
    }
}
